#ifndef __I2DSPRITESCENENODE_H__
#define __I2DSPRITESCENENODE_H__

#include "IDrawableSceneNode.h"

class I2DSpriteSceneNode : public IDrawableSceneNode
{
public:
	I2DSpriteSceneNode(ISceneNodeBasicParamsDeclaration):IDrawableSceneNode(ISceneNodeBasicParams)			{}
	virtual ~I2DSpriteSceneNode()																			{}

	virtual void Render(IDrawableFaceManager *dfm)
	{
		dfm->AddToRenderList2D(de[0]);
	}

	virtual IDrawableFace *GetDrawableFace()	{	return de[0];	}

	virtual vPos GetLenX()
	{
		return de[0]->GetLenX();
	}

	virtual vPos GetLenY()
	{
		return de[0]->GetLenY();
	}

	virtual void SetTextures(ITexture *Texture)
	{
		if (Texture)
		{
			vector2du32 Len = Texture->GetLen();
			vector3dvpos Temp((vPos)(Len.X / (vPos)300.0),(vPos)(Len.Y / (vPos)300.0),(vPos)(0.0));

			CreateFace();
			IDrawableSceneNode::SetTextures(Texture);
		}
	}

	virtual void CreateFace()
	{
		IDrawableFace	*decr;

        vPos X = 0.5;
        vPos Y = 0.5;

		if (de.size() > 0)
		{
			decr = de[0];
		}
		else
		{
			decr = new IDrawableFace(4);
			decr->BeginVectors();
			de.push_back(decr);
		}

		decr->BeginVectors();
		decr->AddVector((vPos)(0.0 - X),(vPos)(0.0 - Y),(vPos)(0.0));
		decr->AddVector((vPos)(0.0 + X),(vPos)(0.0 - Y),(vPos)(0.0));
		decr->AddVector((vPos)(0.0 + X),(vPos)(0.0 + Y),(vPos)(0.0));
		decr->AddVector((vPos)(0.0 - X),(vPos)(0.0 + Y),(vPos)(0.0));
		decr->UpdateNormal();
		decr->EndVectors();
	}

	virtual void SetColor(CColor color)
	{
		SetMaterialAmbients(color);
	}
};
#endif
